<?php
use yii\helpers\Html;
use yii\helpers\Url;
use framework\helpers\Utils;
/* @var $this yii\web\View */
$this->title = '找回登录密码';
?>
<section id="body_h">
		<div class='modular13'>
			<div class="modular12-con1from">
				<form action="<?= Url::to(['site/forgotstep1']);?>" method="post">
                <input type ="hidden" name="_csrf" value="<?php echo yii::$app->request->getCsrfToken();?>" />
					<p class="oneelement greenborder"><input name="name" class="changeelement" placeholder="请输入用户名" type="text"></p>
					<p class="oneelement greenborder"><input name="phone" class="changeelement" placeholder="请输入手机号" type="text"></p>
					<div class="twoelement haveborder">
						<input type="text" name="msgcode" class="changeelement greenborder border-r5 colorb" placeholder="请输入短信验证码">
						<p class="fixedelement2">
							<span id="getcode">获取验证码</span>
						</p>
					</div>
					<div class="twoelement haveborder">
						<input type="text" name="imgcode" class="changeelement greenborder border-r5 colorb" placeholder="请输入图片验证码">
						<p class="fixedelement2">
							<img width="100%" id="imgCode" src="<?= PANDA_SERVER.'/getCAPTCHA?tokenId='.Utils::getTokenId();?>" alt="">
						</p>
					</div><br>
					<p class="mould-2bot form-ok"><input class="form-okbtn b-f" type="submit" value="下一步"></p>
				</form>
			</div>
		</div>
		<section class='text-c'>
			<p>如有任何疑问，请拨打客服电话 <span class="bluecolor">4006-900-880</span> <br>工作时间：09：00-17：30</p>
		</section>
		<div class="footer-h"></div>
</section>
<section id="footer">
		<ul class="footer-nav clearfix">
		    <li>
		        <a href="index.html">
		            <img src="<?= Yii::getAlias('@web') . '/' ?>images/footer1.png" alt="">
		            首页
		        </a>
		    </li>
		    <li class="current-bot">
		        <a href="myaccount.html">
		            <img src="<?= Yii::getAlias('@web') . '/' ?>images/footer2-on.png" alt="">
		            我的账户
		        </a>
		    </li>
		    <li>
		        <a href="about-us.html">
		            <img src="<?= Yii::getAlias('@web') . '/' ?>images/footer3.png" alt="">
		            关于我们
		        </a>
		    </li>
		</ul>
	</section>
	<p id="tip-error"><span>表单验证错误信息</span></p>
<script src="<?= Yii::getAlias('@web') . '/' ?>js/reset.js"></script>
<script>
	$(function($) {
	    var UA=window.navigator.userAgent;  //使用设备
	    var CLICK="click";
	    if(/ipad|iphone|android/.test(UA)){   //判断使用设备
	        CLICK="tap";
	    }
		$(".form-okbtn").click(function(event){
            event.preventDefault();
            var name=$("input[name='name']").val();
            	phone=$("input[name='phone']").val();
            	msgcode=$("input[name='msgcode']").val();
				reg = /^0?1[3|4|5|7|8][0-9]\d{8}$/;
        	if(name == false){
				$('#tip-error span').html('姓名不能为空');
		        $('#tip-error').show();
		        setTimeout(function(){$('#tip-error').fadeOut(500);},1600);
        		$("input[name='name']").focus();
        	}else if(!reg.test(phone)){
				$('#tip-error span').html('请正确输入手机号');
		        $('#tip-error').show();
		        setTimeout(function(){$('#tip-error').fadeOut(500);},1600);
        		$("input[name='phone']").focus();
        	}else if(msgcode == false){
				$('#tip-error span').html('请正确输入短信验证码');
		        $('#tip-error').show();
		        setTimeout(function(){$('#tip-error').fadeOut(500);},1600);
        		$("input[name='msgcode']").focus();
        	}else{
				$(this).parents("form").submit();
			}
		});
		//图片验证码刷新
		$("#imgCode").click(function(){
				document.getElementById("imgCode").src="<?= PANDA_SERVER.'/getCAPTCHA?tokenId='.Utils::getTokenId();?>"+'&'+Math.random();
		});
		//获取短信验证码
		 $('#getcode').click(function(){
		    var name=$("input[name='name']").val();
	        	phone=$("input[name='phone']").val();
				reg = /^0?1[3|4|5|7|8][0-9]\d{8}$/;
	        	if(name == false){
					$('#tip-error span').html('姓名不能为空');
			        $('#tip-error').show();
			        setTimeout(function(){$('#tip-error').fadeOut(500);},1600);
	        		$("input[name='name']").focus();
	        	}else if(!reg.test(phone)){
					$('#tip-error span').html('请正确输入手机号');
			        $('#tip-error').show();
			        setTimeout(function(){$('#tip-error').fadeOut(500);},1600);
	        		$("input[name='phone']").focus();
	        	}else{
					$.post(
							'<?= Url::to('sendlogincode');?>',
							{name:name,phone:phone,'_csrf':'<?= yii::$app->request->getCsrfToken();?>'},
							function(data)
							{
								var obj = eval('(' + data + ')');
								if(obj.msg == '操作成功！' && obj.status == 0)
								{
									$('#tip-error span').html('验证码已发送！');
							        $('#tip-error').show();
							        setTimeout(function(){$('#tip-error').fadeOut(500);},1600);
								}
								else
								{
									$('#tip-error span').html(obj.msg);
							        $('#tip-error').show();
							        setTimeout(function(){$('#tip-error').fadeOut(500);},1600);
								}
							});
				}
		   });
		$(".bodyA").hide();
	});
</script>